package com.usefullc.user.controller;


import com.usefullc.common.constants.SystemConstant;
import com.usefullc.common.enums.SmsCodeTypeEnum;
import com.usefullc.common.enums.UserStatusEnum;
import com.usefullc.common.enums.UserTypeEnum;
import com.usefullc.common.util.BeanUtils;
import com.usefullc.system.controller.WebResultBuilder;
import com.usefullc.system.entity.Pager;
import com.usefullc.system.entity.WebResult;
import com.usefullc.system.param.IdsParam;
import com.usefullc.system.service.component.ImgCodeComponent;
import com.usefullc.system.service.component.SystemConfigComponent;
import com.usefullc.user.domain.Dept;
import com.usefullc.user.domain.Position;
import com.usefullc.user.domain.Role;
import com.usefullc.user.domain.User;
import com.usefullc.user.param.*;
import com.usefullc.user.query.UserQuery;
import com.usefullc.user.service.EmployeeService;
import com.usefullc.user.service.UserService;
import com.usefullc.user.service.component.UserManager;
import com.usefullc.user.vo.LoginResultVo;
import com.usefullc.user.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: Sampson
 * @date: 2022-03-19 12:02
 */
@RestController
@RequestMapping(path = "/user/user1/")
@Api(tags = "后台用户登录管理")
public class LoginController {

    @Autowired
    private ImgCodeComponent imgCodeComponent;

    @Autowired
    private UserService userService;

    @Autowired
    private EmployeeService employeeService;

    @Autowired
    private SystemConfigComponent systemConfigComponent;

//    @ApiOperation(value = "获取图形验证码",  response = WebResult.class)
//    @GetMapping(path = "getImgCode", produces = "application/json")
//    public WebResult getImgCode(HttpServletRequest request) {
//        String deviceId = request.getHeader(SystemConstant.DEVICE_ID);
//        String imgCode = imgCodeComponent.getImgCode(SmsCodeTypeEnum.LOGIN.getCode(), UserTypeEnum.ADMIN.getCode(), deviceId);
//        return WebResultBuilder.successResult(imgCode);
//    }
//
//
//
//    @ApiOperation(value = "用户登录", response = WebResult.class)
//    @PostMapping(path = "login", produces = "application/json")
//    public WebResult login(@RequestBody UserAdminLoginParam param, HttpServletRequest request) {
//        String deviceId = request.getHeader(SystemConstant.DEVICE_ID);
//        User user = userService.loginByPwd(UserTypeEnum.ADMIN.getCode(), param.getAccountNo(), param.getPwd(), param.getImgCode(), deviceId);
//        String token = userService.resetLoginToken(user);
//        LoginResultVo loginResultVo = new LoginResultVo();
//        loginResultVo.setToken(token);
//        UserVo userVo = BeanUtils.beanCopy(user, UserVo.class);
//        loginResultVo.setUserInfo(userVo);
//        return WebResultBuilder.successResult(loginResultVo);
//    }
//
//
//    @ApiOperation(value = "用户注销",  response = WebResult.class)
//    @PostMapping(path = "logout", produces = "application/json")
//    public WebResult logout(HttpServletRequest request) {
//        userService.clearLoginUser(request);
//        return WebResultBuilder.successResult();
//    }




}
